package com.lastoffer2.offerview;

import java.util.List;
import java.util.Locale;

import com.example.lastoffer2.R;
import com.lastct.dao.Offer;
import com.lastoffer2.JSONConnector;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

/**
 * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
 * one of the sections/tabs/pages.
 */
public class SectionsPagerAdapter extends FragmentPagerAdapter {

	private List<Offer> result;

	public SectionsPagerAdapter(FragmentManager fm, List<Offer> result) {
		super(fm);		
		 this.result = result;
	}

	@Override
	public Fragment getItem(int position) {
		// getItem is called to instantiate the fragment for the given page.
		// Return a OfferSectionFragment (defined as a static inner class
		// below) with the page number as its lone argument.
		Fragment fragment = new OfferSectionFragment();
		Bundle args = new Bundle();
		args.putInt(OfferSectionFragment.ARG_SECTION_NUMBER, position + 1);
		fragment.setArguments(args);
		return fragment;
	}

	@Override
	public int getCount() {
				return result.size();
	}

	@Override
	public CharSequence getPageTitle(int position) {
	
		return result.get(position).getName();
	}
}